import {
  q as i,
  p as P,
  ap as ee,
  X as S,
  f as te,
  H as ae,
  av as z,
  aw as se,
  k as t,
  l as a,
  m as s,
  ax as le,
  as as r,
  az as ie,
  at as D,
  ay as ne
} from "./index-b50e6ef9.js";
import { g as N } from "./order-9978affc.js";
function re(p) {
  return (
    typeof p == "function" ||
    (Object.prototype.toString.call(p) === "[object Object]" && !ne(p))
  );
}
function ce(p) {
  const y = i([]),
    F = i([]),
    W = i([]),
    B = i([]),
    E = i({}),
    d = i(!0);
  i({}), P();
  const h = i(1),
    w = i(),
    g = i(10),
    u = i([]),
    I = i(),
    b = i(),
    A = i("nohide"),
    L = ee("reload"),
    v = S({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    V = S({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    J = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      {
        label: "ID",
        prop: "id",
        minWidth: 80,
        formatter: ({ id: e }) => `${e}`
      },
      {
        label: "用户ID",
        prop: "user_id",
        minWidth: 80,
        formatter: ({ user_id: e }) => `1${e}`
      },
      { label: "姓名", prop: "name", minWidth: 130 },
      { label: "手机号", prop: "phone", minWidth: 120 },
      {
        label: "礼品规格",
        prop: "size",
        minWidth: 100,
        formatter: ({ size: e }) =>
          t(
            a("el-tag"),
            { class: "mx-1", type: "success", effect: "light" },
            { default: () => [t("div", { style: "font-size:13px;" }, [e])] }
          )
      },
      {
        label: "地址",
        prop: "address",
        align: "left",
        minWidth: 600,
        formatter: ({ size_address: e, track_code: l }) =>
          t("div", { style: "word-break: break-all;word-wrap: break-word;" }, [
            t("div", null, [e]),
            t("div", null, [
              l
                ? t(
                    a("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    re(l) ? l : { default: () => [l] }
                  )
                : ""
            ])
          ])
      },
      {
        label: "状态",
        prop: "status",
        minWidth: 150,
        formatter: ({ status: e }) =>
          e == 1
            ? t(
                a("el-tag"),
                { class: "mx-1", type: "danger", effect: "light" },
                { default: () => [s("待自提")] }
              )
            : e == 2
            ? t(
                a("el-tag"),
                { class: "mx-1", type: "danger", effect: "light" },
                { default: () => [s("待发货")] }
              )
            : e == 3
            ? t(
                a("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [s("已自提")] }
              )
            : e == 4
            ? t(
                a("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [s("已快递")] }
              )
            : t(
                a("el-tag"),
                { class: "mx-1", type: "info", effect: "light" },
                { default: () => [s("暂无")] }
              )
      },
      {
        label: "下单时间",
        minWidth: 180,
        prop: "create_time",
        formatter: ({ create_time: e }) =>
          typeof e == "number" ? le(e * 1e3).format("YYYY-MM-DD HH:mm:ss") : e
      },
      { label: "操作", fixed: "right", width: 200, slot: "operation" }
    ],
    U = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 80 },
      { label: "订单ID", prop: "order_id", minWidth: 80 },
      { label: "用户名", prop: "user_name", minWidth: 150 },
      {
        label: "身份",
        prop: "user_place",
        minWidth: 100,
        formatter: ({ user_place: e }) => {
          if (e == 0)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("暂无")] }
            );
          if (e == 1)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("一星合伙人")] }
            );
          if (e == 2)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("二星合伙人")] }
            );
          if (e == 3)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("三星合伙人")] }
            );
          if (e == 4)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("四星合伙人")] }
            );
          if (e == 5)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("五星合伙人")] }
            );
          if (e == 6)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("一星联创")] }
            );
          if (e == 7)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("二星联创")] }
            );
          if (e == 8)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("三星联创")] }
            );
          if (e == 9)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("四星联创")] }
            );
          if (e == 10)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("一星董事")] }
            );
          if (e == 11)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("二星董事")] }
            );
          if (e == 12)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("三星董事")] }
            );
        }
      },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      {
        label: "积分",
        prop: "income",
        minWidth: 100,
        formatter: ({ income: e, money: l }) => e || l
      },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e }) => {
          if (e == 1)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("已发放")] }
            );
          if (e == 2)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "info", effect: "light" },
              { default: () => [s("未发放")] }
            );
        }
      },
      { label: "类型", prop: "type_name", minWidth: 100 },
      { label: "来源用户", prop: "source_name", minWidth: 150 },
      { label: "来源用户手机号", prop: "source_phone", minWidth: 120 }
    ],
    k = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 80 },
      { label: "用户ID", prop: "user_id", minWidth: 80 },
      { label: "姓名", prop: "name", minWidth: 130 },
      { label: "手机号", prop: "phone", minWidth: 120 },
      { label: "礼品规格", prop: "size", minWidth: 100 },
      { label: "地址", prop: "size_address", align: "left", minWidth: 600 },
      { label: "状态", prop: "status", minWidth: 150 },
      { label: "下单时间", minWidth: 180, prop: "create_time" },
      { label: "操作", fixed: "right", width: 200, slot: "operation" }
    ],
    O = te(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function R(e) {
    const l = { order_id: e.order_id },
      o = JSON.stringify(l),
      f = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(o)) },
      n = await orderDetail(f);
    n.code == 200 &&
      ((F.value = n.data.income),
      (W.value = n.data.dispel),
      (B.value = n.data.freeze),
      (E.value = n.data.indent));
  }
  async function M(e) {
    ie(e);
  }
  async function j(e) {
    const l = { id: e.id },
      o = JSON.stringify(l),
      f = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(o)) },
      n = await questionDelete(f);
    n.code == 200
      ? (D("删除成功", { type: "success" }), L())
      : D(n.msg, { type: "error" });
  }
  function T() {}
  function Y(e) {
    (g.value = e), x(void 0, e);
  }
  function H(e) {
    (h.value = e), x(e, void 0);
  }
  function _(e) {}
  function $(e) {
    (V.text = `正在加载第${e}页...`),
      (d.value = !0),
      z(600).then(() => {
        d.value = !1;
      });
  }
  async function q(e, l, o = [], c) {
    (u.value = []),
      o.map(K => {
        const Q = K,
          Z = new Date(Q);
        u.value.push(
          Z.toLocaleDateString("zh-CN", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit"
          })
        );
      }),
      (d.value = !0),
      (b.value = e),
      (I.value = l),
      (w.value = c);
    const f = {
        page: h.value,
        pagesize: g.value,
        status: e,
        user_phone: isNaN(l) ? void 0 : l,
        user_name: isNaN(l) ? l : void 0,
        size: c || void 0,
        start: u.value[0],
        end: u.value[1],
        action: "create_time"
      },
      n = JSON.stringify(f),
      G = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(n)) },
      { data: C } = await N(G);
    (y.value = C.data),
      (v.total = C.total),
      setTimeout(() => {
        d.value = !1;
      }, 500);
  }
  async function x(e = h.value, l = g.value) {
    const o = {
        page: e,
        pagesize: l,
        status: b.value,
        start: u.value[0],
        end: u.value[1],
        user_phone: I.value,
        size: w.value,
        action: "create_time"
      },
      c = JSON.stringify(o),
      n = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(c)) },
      m = await N(n);
    m.code === 200
      ? ((y.value = m.data.data),
        (v.total = m.data.total),
        setTimeout(() => {
          d.value = !1;
        }, 500))
      : D(m.msg, { type: "error" });
  }
  const X = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    ae(() => {
      z().then(() => {
        const { setWatermark: e } = se(p.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        x();
    }),
    {
      loading: d,
      columns: J,
      dataList: y,
      userColumns: U,
      pagination: v,
      buttonClass: O,
      userDatilList: F,
      userDatilListDisple: W,
      userDatilListFreeze: B,
      orderInfo: E,
      columnsTable: k,
      count: h,
      pageCount: g,
      formattedDate: u,
      typeCount: b,
      hideVal: A,
      handleLookUserDatil: R,
      onSearch: q,
      resetForm: X,
      handleaddUser: T,
      handleUpdate: M,
      handleDelete: j,
      handleSizeChange: Y,
      handleCurrentChange: H,
      handleSelectionChange: _,
      onCurrentChange: $
    }
  );
}
export { ce as useRole };
